package com.tang.tasks.zentao;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.tasks.TaskRepository;
import com.intellij.tasks.TaskState;
import com.intellij.tasks.config.TaskRepositoryEditor;
import com.intellij.tasks.impl.BaseRepositoryType;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.util.EnumSet;

/**
 * zentao task
 * http://www.zentao.net/
 * Created by TangZX on 2017/1/10.
 */
public class ZentaoTaskRepositoryType extends BaseRepositoryType<ZentaoTaskRepository> {
    @NotNull
    @Override
    public String getName() {
        return "Zentao";
    }

    @NotNull
    @Override
    public Icon getIcon() {
        return AllIcons.Nodes.AbstractClass;
    }

    @NotNull
    @Override
    public TaskRepository createRepository() {
        return new ZentaoTaskRepository(this);
    }

    @Override
    public Class<ZentaoTaskRepository> getRepositoryClass() {
        return ZentaoTaskRepository.class;
    }

    @NotNull
    @Override
    public TaskRepositoryEditor createEditor(ZentaoTaskRepository repository, Project project, Consumer<ZentaoTaskRepository> changeListener) {
        return new ZentaoTaskRepositoryEditor(project, repository, changeListener);
    }

    public EnumSet<TaskState> getPossibleTaskStates() {
        return EnumSet.of(TaskState.OPEN, TaskState.IN_PROGRESS, TaskState.REOPENED, TaskState.RESOLVED);
    }
}
